#! /bin/zsh
set -e
setopt -o EXTENDED_GLOB

SUBSET_ROOT="bpl_subset"
BOOST_ROOT="$1"

rm -Rf "$SUBSET_ROOT"
mkdir "$SUBSET_ROOT"
bcp --boost="$BOOST_ROOT" python thread format ptr_container "$SUBSET_ROOT"

mkdir -p "$SUBSET_ROOT/boost/ptr_container"
cp -R $BOOST_ROOT/boost/ptr_container/* "$SUBSET_ROOT/boost/ptr_container"

for comp in control list repetition; do
  cp -R $BOOST_ROOT/boost/preprocessor/$comp/detail/edg "$SUBSET_ROOT/boost/preprocessor/$comp/detail"
done
for z in "$SUBSET_ROOT"/boost/(*~move~python~config~mpl~smart_ptr~detail~utility~preprocessor~type_traits~exception~function~math~bind~iterator~range~tuple~thread~graph~pending~numeric~date_time~property_map~concept~parameter~optional~multi_index~unordered~functional~integer~ptr_container~container~format~io~units~system~typeof~*hpp); do 
  echo "DELETING $z"
  rm -Rf $z
done
cp $BOOST_ROOT/boost/typeof/incr_registration_group.hpp \
  "$SUBSET_ROOT/boost/typeof/"
cp -Rv $BOOST_ROOT/boost/preprocessor/slot "$SUBSET_ROOT/boost/preprocessor"

rm -Rf "$SUBSET_ROOT"/libs/(*~python~smart_ptr~thread~system)
rm -Rf "$SUBSET_ROOT"/doc
rm -Rf "$SUBSET_ROOT"/boost/typeof/vector{100,150,200}.hpp
rm -Rf "$SUBSET_ROOT"/boost/mpl/aux_/preprocessed/(*~gcc~typeof_based~plain)
rm -Rf "$SUBSET_ROOT"/boost/mpl/vector/aux_/preprocessed/(*~gcc~typeof_based~plain)
rm -Rf "$SUBSET_ROOT"/libs/python/{doc,example,pyste}
find "$SUBSET_ROOT" -name 'Jam*' -delete
rm -Rf "$SUBSET_ROOT"/**/build
rm -Rf "$SUBSET_ROOT"/libs/*/example
rm -Rf "$SUBSET_ROOT"/libs/*/doc
rm -Rf "$SUBSET_ROOT"/libs/*/tutorial
rm -Rf "$SUBSET_ROOT"/**/test
rm -Rf "$SUBSET_ROOT"/libs/python/class.cpp # what the hell is that doing there?
rm "$SUBSET_ROOT"/*.{css,png}

du -sh "$SUBSET_ROOT"
